package com.web.tag;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.shop.entity.UserInfo;

public class IteratorAction extends ActionSupport {
	private List<String> books  =new ArrayList<String>();

	@Override
	public String execute() throws Exception {
		books.add("西游记");
		books.add("大秦帝国");
		books.add("水浒传");
		books.add("JAVA编程思想");
		// 存储对象数据
		UserInfo u1 = new UserInfo("aa", "1111", new Date()) ;
		UserInfo u2 = new UserInfo("bb", "2222", new Date()) ;
		UserInfo u3 = new UserInfo("cc", "3333", new Date()) ;
		List<UserInfo> userList  =Arrays.asList(u1,u2,u3);
		Map<String,Object> session = ActionContext.getContext().getSession();
		session.put("userList", userList);
		//存储map集合
		Map<String,UserInfo> map = new HashMap<String,UserInfo>();
		map.put(u1.getUsername(), u1);
		map.put(u2.getUsername(), u2);
		map.put(u3.getUsername(), u3);
		Map<String,Object> request =(Map<String, Object>) ActionContext.getContext().get("request");
		request.put("map",map);
		return "list";
	}
	
	public List<String> getBooks() {
		return books;
	}

	public void setBooks(List<String> books) {
		this.books = books;
	}
	
	
}
